****
* Recommendations given to firms
****


use  "$data\2_firm_regressions_individual_paper.dta", clear 
keep if wave==1 

// Show only observations where any recommendations were entered 
count if !missing(no_rec_finman) & !missing(no_rec_hr)
local nmiss=r(N)
di "Observations: `nmiss'"
count if no_rec_finman>0 & no_rec_hr>0 & !missing(no_rec_finman) & !missing(no_rec_hr)
local nrec=r(N)
gen nrec=`nrec'
di "Observations with any recommendations: `nrec'"
forv i=1/5 {
	count if no_rec_finman>0 & no_rec_hr>0 & !missing(no_rec_finman) & !missing(no_rec_hr) & consultant==`i'
	local nrec`i'=r(N)
}

*** Recommendations 
collapse (sum) rec_st rec_acc rec_cash rec_form rec_recr rec_compdev rec_conshr rec_orghr (mean) nrec
 
la var rec_st "Financial statements"
la var rec_acc "Accounting"
la var rec_cash "Cash flow"
la var rec_form "Formalization of employment"
la var rec_recr "Recruitment"
la var rec_compdev "Competence development"
la var rec_conshr "Keeping HR"
la var rec_orghr "Organizing HR"

// Order by size of category and define labels and patterns
	local v1="rec_form"
	local lab1	=	"Formalization of employment"	
	local c1	=	"color(navy) fin(inten100)"
	
	local v2="rec_acc"
	local lab2	=	"Accounting"	
	local c2	=	"color(maroon) fin(inten100)"
	
	local v3="rec_cash"
	local lab3	=	"Cash Flow"	
	local c3	=	"color(maroon) fin(inten80)"
	
	local v4="rec_compdev"
	local lab4	=	"Competence Development"	
	local c4	=	"color(navy) fin(inten80)"
	
	local v5="rec_st"
	local lab5	=	"Financial statements"	
	local c5	=	"color(maroon) fin(inten60)"
	
	local v6="rec_orghr"
	local lab6	=	"Organizing HR"	
	local c6	=	"color(navy) fin(inten60)"
	
	local v7="rec_recr"
	local lab7	=	"Recruiting"	
	local c7	=	"color(navy) fin(inten40)"
	
	local v8="rec_conshr"
	local lab8	=	"Keeping HR"	
	local c8	=	"color(navy) fin(inten20)"

*** Graph recommendations 
	sum nrec, d
	graph  hbar  `v1' `v2' `v3' `v4' `v5' `v6' `v7' `v8' , ///
	legend( ///
	lab(1 "`lab1'") ///
	lab(2 "`lab2'") ///
	lab(3 "`lab3'") ///
	lab(4 "`lab4'") ///
	lab(5 "`lab5'") ///
	lab(6 "`lab6'") ///
	lab(7 "`lab7'") ///
	lab(8 "`lab8'")) ///
	bar(1, `c1') ///
	bar(2, `c2') ///
	bar(3, `c3') ///
	bar(4, `c4') ///
	bar(5, `c5') ///
	bar(6, `c6') ///
	bar(7, `c7') ///
	bar(8, `c8') ///
	graphregion(color(white)) ///
	yscale(r(0 `r(mean)')) 


graph export "$results\02_figures\Figure_S2_recommendations.png", as(png) replace 
*graph export "$userpath_writing\Tables\recommendations.tif", as(tif) replace



***
* Number of consultant visits
***

use  "$data\2_firm_regressions_individual_paper.dta", clear 
keep if wave==1 
keep if assignment==1 


	
*** No. of consultant visits 
	count if assignment==1 & no_visits_corrected>0 & !missing(no_visits_corrected)
	local visited=r(N)
	local perc_visited : display %3.2f (100*`visited'/262)
	di "`perc_visited'"

	count if assignment==1 & no_visits_corrected>2 & !missing(no_visits_corrected)
	local visited_2=r(N)
	local perc_visited_2 : display %3.2f (100*`visited_2'/262)
		di "`perc_visited_2'"

	
	
	
/*** Histogram no. of consultant visits */
	graph hbar  , over(no_visits_corrected) ascategory ytitle("% of firms")  bar(1, color(navy*0.4) lcolor(navy)) graphregion(color(white)) nofill



graph export "$results\02_figures\Figure_S2_consultant_visits.png", as(png) replace 
*graph export "$userpath_writing\Tables\consultant_visits.tif", as(tif) replace

